home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 172_01 / system.h < prev    next >
Text File  |  1980-01-01  |  5KB  |  140 lines

  1. /*
  2.   HEADER:              CUG  nnn.nn;
  3.   TITLE:               LEX - A Lexical Analyser Generator
  4.   VERSION:             1.1 for IBM-PC
  5.   DATE:                Jan 30, 1985
  6.   DESCRIPTION:         A Lexical Analyser Generator. From UNIX
  7.   KEYWORDS:            Lexical Analyser Generator YACC C PREP
  8.   SYSTEM:              IBM-PC and Compatiables
  9.   FILENAME:            SYSTEM.H
  10.   WARNINGS:            This program is not for the casual user. It will
  11.                        be useful primarily to expert developers.
  12.   CRC:                 N/A
  13.   SEE-ALSO:            YACC and PREP
  14.   AUTHORS:             Charles H. Forsyth
  15.                        Scott Guthery 11100 leafwood lane Austin, TX 78750
  16.                        Andrew M. Ward, Jr.  Houston, Texas (Modifications)
  17.   COMPILERS:           LATTICE C
  18.   REFERENCES:          UNIX Systems Manuals -- Lex Manual on distribution disks
  19. */
  20. /*
  21.  * Copyright (c) 1978 Charles H. Forsyth
  22.  *
  23.  * Modified 02-Dec-80 Bob Denny -- Conditionalize debug code for reduced size
  24.  * Modified 29-May-81 Bob Denny -- Clean up overlay stuff for RSX.
  25.  * More     19-Mar-82 Bob Denny -- New C library & compiler
  26.  * More     03-May-82 Bob Denny -- Final touches, remove unreferenced autos
  27.  * More     29-Aug-82 Bob Denny -- Clean up -d printouts
  28.  * More     29-Aug-82 Bob Denny -- Reformat for readability and comment
  29.  *                                 while learning about LEX.
  30.  * More     20-Nov-83 Scott Guthery -- Adapt for IBM PC & DeSmet C
  31.  *
  32.  * Modified 22-Jun-86 Andrew Ward -- Modified code to compile under Lattice C
  33.  *                                 version 3.0h.  Corrected several errors
  34.  *                                 from the assumption that pointers and
  35.  *                                 integers are the same size.     
  36.  *                                 New debug code for LATTICE C using assert
  37.  *                                 to test for wild pointers.
  38.  */
  39. /*
  40.  * system.h -- system configuration definitions for lex.c
  41.  *
  42.  */
  43.  
  44. /*
  45.  * Original allocations.
  46.  */
  47. #define NCHARS  0400        /* Size of character set */
  48. #define NCPW       2        /* # characters per word was 2 */
  49. #define NBPC       8        /* # bits per character */
  50. #define NBPW  (NCPW*NBPC)    /* # bits per word */
  51.  
  52. #define MAXNFA   600            /* Number of NFA states */
  53. #define MAXDFA   800        /* Number of DFA states */
  54. #define NTRANS   128        /* Number of translations */
  55. #define NCCLS     50        /* Number of character classes */
  56. #define NNEXT   2400        /* Size of dfa move vectors (later: allocate) */
  57.  
  58. /*
  59.  * Special node characters.
  60.  */
  61. #define CCL     NCHARS          /* One of a character class */
  62. #define EPSILON NCHARS+1        /* Transition on epsilon */
  63. #define FIN     NCHARS+2        /* Final state; NFA */
  64.  
  65. /*
  66.  * Set of state numbers (dfa state name).
  67.  */
  68. struct  set {
  69.         struct set *s_next;
  70.         struct  dfa     *s_state;       /* pointer into dfa array  */
  71.         struct  set     *s_group;       /* pointer to owning group (dfamin) */
  72.         int     s_final;                /* nf state which matches  */
  73.     char    s_flag;                 /* see below */
  74.         int     s_look;                 /* look-ahead bits */
  75.         int     s_len;                  /* number of elements in set */
  76.         struct nfa *s_els[1];             /* was *s_els[1] , but this may be wrong */
  77. };
  78.  
  79. /*
  80.  * State entry
  81.  */
  82. struct  nfa {
  83.         int     n_char;
  84.         char    *n_ccl;
  85.         char    n_flag;
  86.         char    n_look;         /* lookahead index */
  87.         struct  nfa     *n_succ[2];
  88.         struct  trans   *n_trans;
  89. };
  90.  
  91. /*
  92.  * DFA transition entry.
  93.  */
  94. struct  move {
  95.         struct  set     *m_next;
  96.         struct  dfa     *m_check;
  97. };
  98.  
  99. /*
  100.  * Structure of DFA vector.
  101.  */
  102. struct  dfa {
  103.         struct  set     *df_name;
  104.         struct  move    *df_base;
  105.         struct  move    *df_max;
  106.         struct  dfa     *df_default;
  107.         int     df_ntrans;
  108. };
  109.  
  110. /*
  111.  * s_flag values for DFA node
  112.  */
  113.  
  114. #define LOOK    01      /* Lookahead mark */
  115. #define ADDED   02      /* DFA construction mark */
  116. #define FLOOK   04      /* Mark on final state of lookahead translation */
  117.  
  118. /*
  119.  * Flag used to print node
  120.  */
  121. #define NPRT    010     /* NFA node printed */
  122.  
  123. /*
  124.  * Transition set.
  125.  */
  126. struct  xset {
  127.         struct  set     *x_set;
  128.         char    x_char;
  129.         char    x_defsame;
  130. };
  131.  
  132. /*
  133.  * Translations
  134.  */
  135. struct  trans {
  136.     struct  nfa     *t_start;
  137.         struct  nfa     *t_final;
  138. };
  139.  
  140.